import { _decorator, Component, Node, instantiate, Label, Prefab } from 'cc';
import { mb, mb_base_cp, mb_audio } from 'db://magic-book/src';
const { ccclass, property } = _decorator;

@ccclass('audio_layout_state_control')
export class audio_layout_state_control extends mb_base_cp {

    @property(Prefab)
    btn_template: Prefab = null;

    onLoad() {
        const list = [
            "pause_all",
            "resume_all",
            "stop_all",
            "clear_all",
        ];
        for (let i = 0; i < list.length; i++) {
            const node = instantiate(this.btn_template);
            node.on("click", () => {
                mb_audio[node.name]();
            });
            node.name = list[i];
            node.getComponentInChildren(Label).string = node.name;
            this.node.addChild(node);
        }
    }
}

